<template>
	<view>
		<view class="listBox">
			<view class="list" v-for="(item,index) in list">
				<view class="Lcont">
					<u-row>
						<u-col span="6">
							姓名:{{item.name}}
						</u-col>
						<u-col span="6" style="text-align: right;">
							<view class="conts">
								{{item.mobile}}
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" style="padding:10rpx 0;">
							<u-row>
								<u-col span="1">
									<u-icon name="map"></u-icon>
								</u-col>
								<u-col span="10">
									{{item.areaName}}{{item.detailAddress}}
								</u-col>
							</u-row>
						</u-col>
					</u-row>
				</view>
				<view class="Lbtn">
					<u-row>
						<u-col span="6" style="color:#0055ff;">
							{{item.defaultStatus?'默认地址':''}}
						</u-col>
						<u-col span="6">

							<u-row justify="space-between">
								<u-col span="5">
									<u-button :plain="true" size="small" color="#302C29" type="info" shape="circle"
										icon="edit-pen" text="编辑" @click="bianji(item.id)"></u-button>
								</u-col>
								<u-col span="5">
									<u-button :plain="true" @click="del(item.id)" size="small" type="error"
										shape="circle" icon="trash" text="删除"></u-button>
								</u-col>
							</u-row>

						</u-col>
					</u-row>
				</view>
			</view>
		</view>
		<empty v-if="list==''" :emptyData="emptyData"></empty>

		<view class="ubtns">
			<u-button style="margin: 150rpx 25rpx 0;width: 700rpx;" @click="goto('/pages/mine/address')" color="#302C29"
				shape="circle" text="添加地址"></u-button>
		</view>

	</view>
</template>

<script>
	import Empty from '@/pages/public/empty.vue';
	export default {
		components: {
			Empty,
		},
		data() {
			return {
				emptyData: {
					img: '/static/null.png',
					tip: '暂无地址'
				},
				list: []
			}
		},
		onLoad() {

		},
		onShow() {
			this.API_list()
		},
		methods: {
			goto(url) {
				uni.navigateTo({
					url: url
				})
			},
			bianji(id) {
				uni.navigateTo({
					url: '/pages/mine/address?id=' + id,
				})

			},
			del(id) {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '删除地址?',
					success: function(res) {
						if (res.confirm) {
							that.ran
								.request('/app-api/member/address/delete?id=' + id, {
									id: id,
								}, 'DELETE')
								.then(res => {
									console.log(res);
									if (res.code == 200) {
										uni.showToast({
											title: res.msg,
											icon: 'none'
										});
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none'
										});
									}
								});
						} else if (res.cancel) {}
					}

				})

			},
			API_list() {
				var that = this;
				that.ran
					.request('/app-api/member/address/list', {}, 'GET')
					.then(res => {
						console.log(res);
						if (res.code == 200) {
							that.list = res.data;
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						}
					});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f8f8f8;
	}

	.listBox {
		.list {
			padding: 10rpx 0rpx;
			margin: 25rpx 25rpx 0;
			border-radius: 10rpx;
			background: #fff;
			overflow: hidden;

			.Lcont {
				padding: 10rpx 20rpx;
				line-height: 60rpx;
				font-size: 26rpx;

				.title {}

				.conts {
					color: #666;
				}
			}

			.Lbtn {
				padding: 10rpx 20rpx;
				line-height: 60rpx;
				font-size: 26rpx;
				overflow: hidden;

				.conts {
					color: #666;
				}
			}

			.Ltop {
				background-image: linear-gradient(to bottom right, #e5e5e5, #f4f4f4);
				line-height: 60rpx;
				padding: 0 20rpx;

				.s1 {
					color: #302C29;
				}

				.s2 {
					color: #0055ff;
				}

				.stutic {
					font-size: 24rpx;
					text-align: right;
				}

				.no {
					font-size: 24rpx;
					font-weight: bold;
				}
			}
		}
	}

	.tab {
		text-align: center;
		line-height: 80rpx;
		border-bottom: 1rpx solid #eee;
	}

	.tabck {
		color: #302C29;
		font-weight: bold;
		// border-bottom: 4rpx solid #302C29 !important;
		position: relative;
	}

	.tabck::after {
		content: ''; // 必须
		position: absolute;
		left: -50rpx;
		margin-left: 50%;
		bottom: 0;
		right: 0;
		width: 100rpx;
		height: 4px;
		border-radius: 10rpx;
		background-color: #302C29;
	}
</style>